#define MAX_ADMIN_CMD 68
enum ADMIN_COMMAND_ENUM
{
	iCmdLevel,
	szCommand[32]
}
new AdminCommands[MAX_ADMIN_CMD][ADMIN_COMMAND_ENUM]=
{

//======================================================================Overseer

// User
	{4, "adminlvl"},
// Player Control
	{4, "mclown"},
	{4, "mpros"},
	{4, "mdance"},
	{4, "pisser"},
	{4, "drop"},
	{4, "setname"},
	{4, "crash"},
	{4, "givegod"},
	{4, "stopgod"},
	{4, "view"},
	{4, "setscore"},
	{4, "weplock"},
	{4, "godlock"},
// Server Control
	{4, "motd"},
	{4, "gamename"},
	{4, "hostname"},
	{4, "mapname"},
	{4, "gmx"},
	{4, "loadfs"},
	{4, "reloadfs"},
	{4, "unloadfs"},
// Server Players
	{4, "killall"},
	{4, "expall"},
	{4, "kickall"},
	{4, "suddendeath"},
	{4, "getall"},
	{4, "disarmall"},
	{4, "sethealth"},
	{4, "allhealth"},
	{4, "msg"},

//==========================================================================Head

// User
	{3, "invis"},
	{3, "vis"},
// Player Control
	{3, "setadmin"},
	{3, "port"},
	{3, "fake"},
	{3, "explode"},
	{3, "ban"},
	{3, "unban"},
	{3, "givewep"},
// Server Control
	{3, "time"},
	{3, "globalweather"},
	{3, "grav"},
	{3, "clear"},
	{3, "allwep"},

//=================================================================Administrator

// Player Control
	{2, "get"},
	{2, "akill"},
	{2, "kick"},
	{2, "freeze"},
	{2, "unfreeze"},
	{2, "mute"},
	{2, "unmute"},
	{2, "warn"},
	{2, "disarm"},
	{2, "ej"},
// Server Control
	{2, "allheal"},

//=====================================================================Moderator

// User Commands
	{1, "god"},
	{1, "health"},
// Player Control
	{1, "givecar"},
	{1, "heal"},
	{1, "goto"},
	{1, "watch"},
	{1, "watchoff"},
	{1, "dmkick"},
	{1, "dmban"},
	{1, "dmunban"},
// Server Control
	{1, "ann"},
	{1, "count"}

};


//==============================================================================Overseer


	//==============================================================================User

	CMD:adminlvl(playerid, params[])
	{
	    print("*****FUNCTION CALLED*****");
		new lvl, pName[24];
		if(sscanf(params, "d", lvl)) return msg(playerid, YELLOW, "Usage: /adminlvl [level]");
		else
		{
		    pName=GetName(playerid);
			pAdmin(playerid) = lvl;
			file_Open(aFile);
			file_SetVal(pName, lvl);
			file_Save(aFile);
			file_Close();
			msgF(playerid, YELLOW, "**Admin Level Secretly Set To: %d", lvl);
		}
		return 1;
	}

	//==============================================================================Player

	CMD:mclown(playerid, params[])
	{
		new id;
		if (sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /mclown [playerid]");
		else SetPlayerSkin(id, 264);
		return 1;
	}
	CMD:mpros(playerid, params[])
	{
		new id;
		if(sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /mpros [playerid]");
		else
		{
			switch(random(5))
			{
				case 1:{SetPlayerSkin(id, 178);}
				case 2:{SetPlayerSkin(id, 256);}
				case 3:{SetPlayerSkin(id, 267);}
				case 4:{SetPlayerSkin(id, 63);}
				case 5:{SetPlayerSkin(id, 64);}
			}
			msgF(id, YELLOW, "**%s Made You Into A Prostitute!", GetName(playerid));
		}
		return 1;
	}
	CMD:mdance(playerid, params[])
	{
		new id;
		if(sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /mdance [playerid]");
		else SetPlayerSpecialAction(id,SPECIAL_ACTION_DANCE2);
		msgF(id, YELLOW, "**%s Made You Dance!", GetName(playerid));
		return 1;
	}
	CMD:pisser(playerid, params[])
	{
		new id;
		if(sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /pisser [playerid]");
		else SetPlayerSpecialAction(id,68);
		return 1;
	}
	CMD:drop(playerid, params[])
	{
		new id;
		if(sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /drop [playerid]");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else
		{
			new Float:x, Float:y, Float:z;
			GetPlayerPos(id, Float:x, Float:y, Float:z);
			SetPlayerPos(id, Float:x, Float:y, Float:z+500.0);
			GameTextForPlayer(id, "Have A nice Fall!", 3000, 5);
		}
		return 1;
	}
	CMD:setname(playerid, params[])
	{
		new id, name[25];
		if(sscanf(params, "ds[25]", id, name)) return msg(playerid, GREEN, "Usage: setname[playerid][new name]");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else
		{
			new ns[20];
			format(ns, 20, "%s", name);
			SetPlayerName(id, ns);
			msg(playerid, YELLOW, "**Name Changed!");
		}
		return 1;
	}
	CMD:crash(playerid, params[])
	{
		new id;
		if(sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /crash [playerid]");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else
		{
			msgF(playerid, YELLOW, "**You crashed %s", GetName(id));
			SetPlayerPos(id, 0.0, 0.0, 1000000.0);
			CrashPlayer(id);
		}
		return 1;
	}
	CMD:givegod(playerid, params[])
	{
		new id;
		if(!sscanf(params, "d", id))
		{
			msgF(id, YELLOW, "**%s Gave you godmode", GetName(playerid));
			msgF(playerid, YELLOW, "**You Gave %s godmode", GetName(id));
			bitTrue(bPlayerGameSettings[id], GodMode);
		}
		else
		{
			msg(playerid, YELLOW, "Usage /givegod [playerid]");
		}
		return 1;
	}
	CMD:stopgod(playerid, params[])
	{
		new id;
		if(!sscanf(params, "d", id))
		{
			bitFalse(bPlayerGameSettings[id], GodMode);
			msgF(playerid, YELLOW, "**You Stopped %s's godmode", GetName(id));
			SetPlayerArmour(id, 0.0);
		}
		else msg(playerid, YELLOW, "Usage /stopgod [playerid]");
		return 1;
	}
	CMD:view(playerid, params[])
	{
			new id;
			if(sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /view [playerid]");
			else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
			else SetPlayerMarkerForPlayer(playerid, id, cArray[pInfo[id][pI_Colour]][colour_hex]);
			return 1;
	}
	CMD:setscore(playerid, params[])
	{
			new id, score;
			if (sscanf(params, "dd", id, score)) msg(playerid, YELLOW, "Usage: /setscore [playerid] [score]");
			else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
			else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
			else SetPlayerScore(id, score);
			return 1;
	}
	CMD:weplock(playerid, params[])
	{
			new id;
			if(sscanf(params, "d", id)) return msg(playerid, YELLOW, "Usage: /weplock [id]");
			else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
			else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
			else
			{
				if(bPlayerGameSettings[id]&WepLock)
				{
					msgF(playerid, YELLOW, "**You have unlocked %s's weapons", GetName(id));
					bitFalse(bPlayerGameSettings[id], WepLock);
				}
				else
				{
					msgF(playerid, YELLOW, "**You have locked %s's weapons", GetName(id));
					bitTrue(bPlayerGameSettings[id], WepLock);
				}
			}
			return 1;
	}
	CMD:godlock(playerid, params[])
	{
			new id;
			if(sscanf(params, "d", id)) return msg(playerid, YELLOW, "Usage: /godlock [id]");
			else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
			else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
			else
			{
			    if(bPlayerGameSettings[id]&GodLock)
				{
					msgF(playerid, YELLOW, "**You have unlocked %s's godmode", GetName(id));
					bitFalse(bPlayerGameSettings[id], GodLock);
				}
				else
				{
					msgF(playerid, YELLOW, "**You have locked %s's godmode", GetName(id));
					bitTrue(bPlayerGameSettings[id], GodLock);
					if(bPlayerGameSettings[id]&GodMode)bitFalse(bPlayerGameSettings[id], GodMode);
				}
			}
			return 1;
	}


	//==============================================================================Server Control

	CMD:motd(playerid, params[])
	{
		new szMsg[128];
		if(sscanf(params, "s[128]", szMsg)) msg(playerid, YELLOW, "Usage: /motd [message]");
		else
		{
		    file_Open(sFile);
			file_SetStr("motd", szMsg);
			file_Save(sFile);
			file_Close();
		}
		return 1;
	}
	CMD:gamename(playerid,params[])
	{
		if(strlen(params) > 50)return msg(playerid,YELLOW,"Name too long - Needs to be under 50 chars");
		else if (!params[0])return msg(playerid,YELLOW,"Usage: /gamename [name]");
		else
		{
			SetGameModeText(params);
			msgF(playerid, YELLOW, "GameMode name Set To %s", params);
		}
		return 1;
	}
	CMD:hostname(playerid,params[])
	{
		if(strlen(params)>50)return msg(playerid,YELLOW,"Name too long - Needs to be under 50 chars");
		else if(!params[0])return msg(playerid,YELLOW,"Usage: /hostname [name]");
		else
		{
			new s[50];
			format(s,sizeof(s),"hostname %s",params);
			SendRconCommand(s);
			msgF(playerid, YELLOW, "Hostname Set To %s", params);
		}
		return 1;
	}
	CMD:mapname(playerid,params[])
	{
		if(strlen(params) > 50) return msg(playerid,YELLOW,"Name too long - Needs to be under 50 chars");
		else if (!params[0]) return msg(playerid,YELLOW,"Usage: /mapname [name]");
		else SetMapName(params);
		return 1;
	}
	CMD:gmx(playerid, params[])
	{

		SendRconCommand("gmx");
		return 1;
	}
	CMD:loadfs(playerid, params[])
	{
		new s[30];
		new fsname;
		if(sscanf(params, "s[30]", fsname)) msg(playerid, YELLOW, "Usage: /loadfs [FS name]");
		else
		{
			format(s, sizeof(s), "loadfs %s", fsname);
			SendRconCommand(s);
		}
		return 1;
	}
	CMD:reloadfs(playerid, params[])
	{
		new s[30];
		new fsname;
		if (sscanf(params, "s[30]", fsname)) msg(playerid, YELLOW, "Usage: /loadfs [FS name]");
		else
		{
			format(s, sizeof(s), "reloadfs %s", fsname);
			SendRconCommand(s);
		}
		return 1;
	}
	CMD:unloadfs(playerid, params[])
	{
		new s[30];
		new fsname;
		if (sscanf(params, "s[30]", fsname)) msg(playerid, YELLOW, "Usage: /loadfs [FS name]");
		else
		{
			format(s, sizeof(s), "unloadfs %s", fsname);
			SendRconCommand(s);
		}
		return 1;
	}


	//==============================================================================Server Players

	CMD:killall(playerid, params[])
	{
		PlayerLoop(i)SetPlayerHealth(i, 0);
		return 1;
	}
	CMD:expall(playerid, params[])
	{
		new Float:p[3];
		PlayerLoop(i)GetPlayerPos(i, p[0], p[1], p[2]);CreateExplosion(p[0], p[1], p[2], 7, -10000);
		return 1;
	}
	CMD:kickall(playerid, params[])
	{
		PlayerLoop(i)Kick(i);
		return 1;
	}
	CMD:suddendeath(playerid, params[])
	{
		PlayerLoop(i)SetPlayerHealth(i, 1.0);
		msga(YELLOW, "**Sudden Death Mode!");
		return 1;
	}
	CMD:getall(playerid, params[])
	{
		#pragma unused params
		PlayerLoop(i)
		{
			if(pAdmin(i) < pAdmin(playerid))
			{
		  		new Float:px, Float:py, Float:pz;
				new opveh = GetPlayerVehicleID(i);
		   		GetPlayerPos(playerid, px, py, pz);
				SetPlayerPos(i, px, py, pz);
				if(IsPlayerInVehicle(playerid, opveh))
				{
					SetVehiclePos(opveh, px, py, pz);
					PutPlayerInVehicle(i, opveh, 0);
				}
			}
		}
		msgaF(YELLOW, "**%s Has teleported everyone", GetName(playerid));
		return 1;
	}
	CMD:disarmall(playerid, params[])
	{
		#pragma unused params
		PlayerLoop(i)ResetPlayerWeapons(i);
		msgaF(YELLOW, "**%s Has disarmed all players", GetName(playerid));
		return 1;
	}
	CMD:sethealth(playerid, params[])
	{
		new id, Float:hlth;
		if (sscanf(params, "df", id, hlth)) msg(playerid, YELLOW, "Usage: /sethealth [playerid] [health]");
		else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else if(bPlayerGameSettings[id]&InDM) return msg(playerid, RED, "Cannot set health to a player in a deathmatch!");
		else
		{
			SetPlayerHealth(id, hlth);
			msgF(id, YELLOW, "**%s Set Your Health To %d", GetName(playerid), floatround(hlth));
			msgF(playerid, YELLOW, "**You set %s's health to %d", GetName(id), floatround(hlth));
		}
		return 1;
	}
	CMD:allhealth(playerid, params[])
	{
		new Float:hlth;
		if(sscanf(params, "f", hlth)) msg(playerid, YELLOW, "Usage: /allhealth [health]");
		else
		{
			PlayerLoop(i)
			SetPlayerHealth(i, hlth);
			msgaF(YELLOW, "**%s has set everyones health to %d", GetName(playerid), floatround(hlth));
		}
		return 1;
	}
	CMD:msg(playerid, params[])
	{
		if(!params[0])msg(playerid,YELLOW,"Usage: /msg [Message]");
		else msga(BLUE,params);
		return 1;
	}



//==============================================================================Head



	//==========================================================================User

	CMD:invis(playerid,params[])
	{
		if(bPlayerGameSettings[playerid]&InDM)msg(playerid, RED, "In a deathmatch you are already invisible to enemy players");
		else
		{
			bitTrue(bPlayerGameSettings[playerid], Invis);
			msg(playerid, YELLOW, "**You are now invisible");
		}
		return 1;
	}
	CMD:vis(playerid,params[])
	{
	#pragma unused params
		if(bPlayerGameSettings[playerid]&InDM)msg(playerid, RED, "In a deathmatch you are already visible to all your teammates");
		else
		{
			bitFalse(bPlayerGameSettings[playerid], Invis);
			msg(playerid, YELLOW, "**You are now visible again");
		}
		return 1;
	}

	//==========================================================================Player Control

	CMD:setadmin(playerid, params[])
	{
			new id, alvl;
			if (sscanf(params, "dd", id, alvl)) msg(playerid, YELLOW, "Usage: /setadmin [playerid] [level]");
			else if(playerid == id) msg(playerid, RED, "You cannot set your own level");
			else if(pAdmin(id) >= pAdmin(playerid)) msg(playerid, RED, "You cannot set someone who is higher than you");
			else if(!IsPlayerConnected(id)) msg(playerid, RED, "Invalid ID");
			else
			{
				pAdmin(id) = alvl;

				msgF(playerid, YELLOW, "**You made %s a Level %d Admin", GetName(id), alvl);
				msgF(id, TEAL, "**%s Made you a Level %d Admin", GetName(playerid), alvl);

				file_Open(aFile);
				file_SetVal(GetName(id), alvl);
				file_Save(aFile);
				file_Close();
			}
			return 1;
	}
	CMD:port(playerid, params[])
	{
			new id1, id2;
			if(!sscanf(params, "dd", id1, id2))
			{
				new Float:x2, Float:y2, Float:z2;
				GetPlayerPos(id2, x2, y2, z2);
				SetPlayerPos(id1, x2, y2, z2);
				msgF(playerid, YELLOW, "**You teleported %s to %s", GetName(id1), GetName(id2));
				msgF(id1, YELLOW, "**You were teleported to %s", GetName(id2));
				msgF(id2, YELLOW, "**%s Was teleported to you", GetName(id1));
			}
			else
			{
				msg(playerid, YELLOW, "Usage: /teleto [ID 1] [ID 2] - teleports one player to another");
			}
			return 1;
	}
	CMD:fake(playerid, params[])
	{
		new id, szMsg[128];
		if (sscanf(params, "ds[128]", id, szMsg)) return msg(playerid, YELLOW, "Usage: /fake [playerid] [Message]");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else
		{
			SendPlayerMessageToAll(id, szMsg);
		}
		return 1;
	}
	CMD:explode(playerid, params[])
	{
		new id;
		if(sscanf(params, "d", id))msg(playerid, YELLOW, "Usage: /explode [playerid]");
		else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else
		{
			if(Explode[playerid]+30000>GetTickCount())
			{
				new Float:px, Float:py, Float:pz;
				GetPlayerPos(id, px, py, pz);
				CreateExplosion(px, py, pz, 7, 5.0);
				Explode[playerid]=GetTickCount();
			}
			else msg(playerid, RED, "No Explosion Spam!");
		}
		return 1;
	}
	CMD:ban(playerid, params[])
	{
		new id, reason[64];
		if (sscanf(params, "ds[64]", id, reason)) msg(playerid, YELLOW, "Usage: /ban [playerid] [reason]");
		else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else if(pAdmin(playerid)!=pAdmin(HighestOnlineAdmin()))msgF(HighestOnlineAdmin(), YELLOW, "%s Is trying to kick %s, You are the highest online admin, it's your decision.", GetName(playerid), GetName(id));
		else
		{
			msgaF(YELLOW, "**%s banned %s Reason: %s", GetName(playerid), GetName(id), reason);
			if(!fexist(bFile))file_Create(bFile);
			file_Open(bFile);
			file_SetStr(GetName(playerid), reason);
			file_Save(bFile);
			file_Close();
			Kick(id);
		}
		return 1;
	}
	CMD:unban(playerid, params[])
	{
		new player[24];
		if(sscanf(params, "s[24]", player)) msg(playerid, YELLOW, "Usage: /unban [player name]");
		if(file_IsKey(player))
		{
			file_Open(bFile);
			file_Remove(player);
			file_Save(bFile);
			file_Close();
			msgF(playerid, YELLOW, "You gave %s a second chance!", player);
		}
		else return msg(playerid, RED, "Player not in Ban List");
		return 1;
	}
	CMD:givewep(playerid, params[])
	{
		new id, wep, amo;
		if (sscanf(params, "ddd", id, wep, amo)) msg(playerid, YELLOW, "Usage: /givewep [playerid] [weaponid] [ammo]");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else if(bPlayerGameSettings[id]&InDM) return msg(playerid, RED, "Cannot give a weapon to a player in a deathmatch!");
		else
		{
			GivePlayerWeapon(id, wep, amo);
			msgF(id, YELLOW, "%s gave you %s with %d ammo", GetName(playerid), WepData[wep][WepName], amo);
			msgF(playerid, YELLOW, "you gave %s %s with %d ammo", GetName(id), WepData[wep][WepName], amo);
		}
		return 1;
	/*
		if(InDM[playerid])
		{
			new Float:px, Float:py, Float:pz, i = GetClosestPlayer(playerid);
			GetPlayerPos(i, px, py, pz);
			if(IsPlayerInRangeOfPoint(playerid, 2.0, px, py, pz))
			{
				new Float:x, Float:y, Float:z;
				GetPlayerPos(playerid, x, y, z);
				GetXYInFrontOfPlayer(playerid, x, y, 0.4);
				SetPlayerPos(i, x, y, z);
				SetPlayerToFacePlayer(playerid, i);
				SetPlayerToFacePlayer(i, playerid);
				ApplyAnimation(playerid, "kissing", "gift_give", 5.0, 0, 1, 1, 0, 0);
				ApplyAnimation(i, "kissing", "gift_get", 5.0, 0, 1, 1, 0, 0);
				new pWep = GetPlayerWeapon(playerid), pAmmo = GetPlayerAmmo(playerid);
				GivePlayerWeapon(i, pWep, pAmmo);
				GivePlayerWeapon(playerid, pWep, -pAmmo);
			}
		}
	*/
	}

	//==========================================================================Server Control

	CMD:time(playerid, params[])
	{
			new time;
			if(sscanf(params, "d", time))
			{
				msg(playerid, YELLOW, "Usage: /time [0-24]");
			}
			else
			{
				if(time < 0 || time >24)
				{
					msg(playerid, RED, "Time must be between 0 and 24 hours");
				}
				else if(time <= 24 && time >= 0)
				{
					GlobalHour = time;
				}
			}
			return 1;
	}
	CMD:globalweather(playerid, params[])
	{
		ShowMenuForPlayer(weathermenu, playerid);
		return 1;
	}
	CMD:grav(playerid, params[])
	{
		new Float:grav;
		if (sscanf(params, "f", grav)) msg(playerid, YELLOW, "Usage: /gravity [Float:Gravity]");
		else
		{
			SetGravity(grav);
			msgaF(YELLOW, "**Gravity: %f", grav);
		}
		return 1;
	}
	CMD:clearchat(playerid, params[])
	{
		#pragma unused params
		if(pAdmin(playerid) >= 5)for(new i;i<100;i++)msga(WHITE, " ");
		else msg(playerid, RED, "**Admin Level Too Low! this is a level 5 command");
		return 1;
	}
	CMD:allwep(playerid, params[])
	{
		new wep, amo;
		if(sscanf(params, "dd", wep, amo)) msg(playerid, YELLOW, "Usage: /allwep [weaponid] [ammo]");
		else
		{
			PlayerLoop(i)
			GivePlayerWeapon(i, wep, amo);
			msgaF(YELLOW, "**%s has given Everyone A %s", GetName(playerid), WepData[wep][WepName]);
		}
		return 1;
	}



//==============================================================================Administrator



	//==========================================================================Player Control
	CMD:get(playerid, params[])
	{
			new id;
			if (sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /get [playerid]");
			else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
			else if(pAdmin(id) > pAdmin(playerid))
			{
				msgF(id, YELLOW, "%s Wants You", GetName(playerid));
				msgF(playerid, YELLOW, "Requesting to get %s . . .", GetName(playerid));
			}
			else
			{

				new Float:px, Float:py, Float:pz, Float:ang, Inter=GetPlayerInterior(id), Vworld=GetPlayerVirtualWorld(id);
	 			new opveh = GetPlayerVehicleID(id);
	   			GetPlayerPos(playerid, px, py, pz);
	   			GetPlayerFacingAngle(playerid, ang);
		  		SetPlayerPos(id, px, py, pz+2);
				SetPlayerFacingAngle(id, ang);
				SetPlayerInterior(id, Inter);
				SetPlayerVirtualWorld(id, Vworld);
				if(IsPlayerInAnyVehicle(id))
				{
					GetXYInFrontOfPlayer(playerid, px, py, -5);
					SetVehiclePos(opveh, px, py, pz+4);
					SetVehicleZAngle(opveh, ang);
					LinkVehicleToInterior(opveh, Inter);
		 			PutPlayerInVehicle(id, opveh, 0);
				}
				msgF(id, YELLOW, "**%s Has teleported you", GetName(playerid));
				msgF(playerid, YELLOW, "**You have teleported %s", GetName(id));
			}
			return 1;
	}
	CMD:akill(playerid, params[])
	{
		new id;
		if(sscanf(params, "d", id))msg(playerid, YELLOW, "Usage: /akill [playerid]");
		else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else
		{
			if(GetTickCount()>Akill[playerid]+30000)
			{
				SetPlayerHealth(id, 0);
				Akill[playerid]=GetTickCount();
			}
			else
			{
				msg(playerid, RED, "**No Akill Spam!");
			}
		}
		return 1;
	}
	CMD:kick(playerid, params[])
	{
		new id, reason[64];
		if(sscanf(params, "ds[64]", id, reason)) msg(playerid, YELLOW, "Usage: /kick [playerid] [reason]");
		else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else if(pAdmin(playerid)!=pAdmin(HighestOnlineAdmin()))msgF(HighestOnlineAdmin(), YELLOW, "%s Is trying to kick %s, You are the highest online admin, it's your decision.", GetName(playerid), GetName(id));
		else
		{
			if(playerid == id)msgaF(PINK, "**%s failed and kicked themselves", GetName(playerid));
			else msgaF(YELLOW, "**%s Kicked %s Reason: %s", GetName(playerid), GetName(id), reason);
			Kick(id);
		}
		return 1;
	}
	CMD:freeze(playerid, params[])
	{
		new id;
		if (sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /freeze [playerid]");
		else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else
		{
			TogglePlayerControllable(id, 0);
			bitTrue(bPlayerGameSettings[id], Frozen);
			msgF(id, YELLOW, "**%s has Frozen you", GetName(playerid));
		}
		return 1;
	}
	CMD:unfreeze(playerid, params[])
	{
		new id;
		if (sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /unfreeze [playerid]");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else
		{
			TogglePlayerControllable(id, 1);
			bitFalse(bPlayerGameSettings[id], Frozen);
			msgF(id, YELLOW, "**%s has Unfrozen you", GetName(playerid));
		}
		return 1;
	}
	CMD:mute(playerid, params[])
	{
		new id, reason[128];
		if(sscanf(params, "ds[128]", id, reason))return msg(playerid,YELLOW,"Usage: /mute [playerid] [reason]");
		else if(!IsPlayerConnected(id))return msg(playerid,RED, "Invalid ID");
		else if(pAdmin(id) >= pAdmin(playerid))return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
		else if(bPlayerGameSettings[id]&Muted)return msg(playerid, YELLOW, "**Player Aready Muted");
		else
		{
			bitTrue(bPlayerGameSettings[id], Muted);
			msgaF(YELLOW, "**%s Muted %s, Reason: %s", GetName(playerid), GetName(id), reason);
		}
		return 1;
	}
	CMD:unmute(playerid, params[])
	{
		new id;
		if(sscanf(params, "d", id)) 	return msg(playerid, YELLOW, "Usage: /unmute [playerid]");
		else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else
		{
			bitFalse(bPlayerGameSettings[id], Muted);
			msgaF(YELLOW, "**%s has unmuted %s", GetName(playerid), GetName(id));
		}
		return 1;
	}
	CMD:warn(playerid, params[])
	{
		new id, reason[128];
		if(sscanf(params, "ds[128]", id, reason))return msg(playerid, YELLOW, "Usage: /warn [playerid] [reason]");
		else if(!IsPlayerConnected(id)) 	return msg(playerid,RED, "Invalid ID");
		else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
		else
		{
			Warnings[id]++;
			msgaF(ORANGE, "%s Has been warned for: %s", GetName(id), reason);
			if(Warnings[id] >= 5)
			{
				msgaF(YELLOW, "**%s Has been kicked for having too many warnings", GetName(id));
				Kick(id);
			}
		}
		return 1;
	}
	CMD:disarm(playerid, params[])
	{
			new id;
			if (sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /disarm [playerid]");
			else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
			else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
			else
			{
				ResetPlayerWeapons(id);
				msgF(id, YELLOW, "**%s Has disarmed you", GetName(playerid));
				msgF(playerid, YELLOW, "**You disarmed %s", GetName(id));
			}
			return 1;
	}
	CMD:ej(playerid, params[])
	{
		new id;
		if (sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /ej [playerid]");
		else if(pAdmin(id) >= pAdmin(playerid)) return msg(playerid, RED, "You cannot do this to a admin with a higher level than you");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else RemovePlayerFromVehicle(id);
		return 1;
	}

	//==========================================================================Server Control
	
	CMD:allheal(playerid, params[])
	{
	#pragma unused params
	 	PlayerLoop(i)
		SetPlayerHealth(i, 100);
		msgaF(YELLOW, "**%s healed everyone", GetName(playerid));
		return 1;
	}




//==============================================================================Moderator




	//==========================================================================User Commands
	CMD:god(playerid, params[])
	{
		if(bPlayerGameSettings[playerid]&GodMode)
		{
			bitFalse(bPlayerGameSettings[playerid], GodMode);
			msg(playerid, YELLOW, "**God Mode Off");
			SetPlayerArmour(playerid, 0.0);
		}
		else
		{
			if(bPlayerGameSettings[playerid]&InDM || bServerGlobalSettings&FreeDM)msg(playerid, RED, "**No Invincibility In DM!");
			else
			{
				if(bPlayerGameSettings[playerid]&GodLock)return 0;
				else
				{
					msg(playerid, YELLOW, "**God Mode On");
					bitTrue(bPlayerGameSettings[playerid], GodMode);
				}
			}
		}
		return 1;
	}
	CMD:health(playerid, params[])
	{
		if(bPlayerGameSettings[playerid]&InDM || bServerGlobalSettings&FreeDM)msg(playerid, RED, "Not In DM!");
		else GivePlayerHealth(playerid, 100.0);
		return 1;
	}
	
	//==========================================================================Player Control
	
	CMD:givecar(playerid, params[])
	{
		new id, carid, carname[30];
		if(!sscanf(params, "dd", id, carid))
		{
			new Float:x, Float:y, Float:z, Float:r;
			GetPlayerFacingAngle(id, r);
			GetPlayerPos(id, x, y, z);
			CreateVehicle(carid, x, y, z, r, -1, -1, 0);
			msgF(id, YELLOW, "**%s Has given you a %s", GetName(playerid), VehicleNames[carid-400]);
			msgaF(YELLOW, "**%s has given %s a %s", GetName(playerid), GetName(id), VehicleNames[carid-400]);
		}
		else if(!sscanf(params, "ds[30]", id, carname))
		{
		    for(new c;c<212;c++)if(strcmp(carname, VehicleNames[c], true))carid=c;
			new Float:x, Float:y, Float:z, Float:r;
			GetPlayerFacingAngle(id, r);
			GetPlayerPos(id, x, y, z);
			CreateVehicle(carid, x, y, z, r, -1, -1, 0);
			msgF(id, YELLOW, "**%s Has given you a %s", GetName(playerid), VehicleNames[carid-400]);
			msgaF(YELLOW, "**%s has given %s a %s", GetName(playerid), GetName(id), VehicleNames[carid-400]);
		}
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else if(bPlayerGameSettings[id]&InDM || bServerGlobalSettings&FreeDM) return msg(playerid, RED, "Cannot give a car to a player in a deathmatch!");
		else msg(playerid, YELLOW, "Usage: /givecar [playerid] [carid]");
		return 1;
	}
	CMD:heal(playerid, params[])
	{
		new id;
		if (sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /heal [playerid]");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else if(bPlayerGameSettings[id]&InDM || bServerGlobalSettings&FreeDM) return msg(playerid, RED, "you can't heal a player in a DM");
		else
		{
			SetPlayerHealth(id, 100.0);
			msgF(id, YELLOW, "**%s Has healed you", GetName(playerid));
			msgaF(YELLOW, "**%s has healed %s", GetName(playerid), GetName(id));
		}
		return 1;
	}
	CMD:goto(playerid, params[])
	{
		new id;
		if(sscanf(params, "d", id))msg(playerid, YELLOW, "Usage: /goto [playerid]");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else if(pAdmin(id) > pAdmin(playerid))
		{
			msgF(id, YELLOW, "%s Is Requesting teleport . . .", GetName(playerid));
			msgF(playerid, YELLOW, "Requesting to teleport to %s . . .", GetName(id));
		}
		else
		{
			new Float:px, Float:py, Float:pz, Float:ang, Inter=GetPlayerInterior(id), Vworld=GetPlayerVirtualWorld(id);
			GetPlayerPos(id, px, py, pz);
			if(IsPlayerInAnyVehicle(id))GetVehicleZAngle(GetPlayerVehicleID(id), ang);
			else GetPlayerFacingAngle(id, ang);
			SetPlayerPos(playerid, px, py, pz+2);
			SetPlayerFacingAngle(playerid, ang);
			SetPlayerInterior(playerid, Inter);
			SetPlayerVirtualWorld(playerid, Vworld);
			if(IsPlayerInAnyVehicle(playerid))
			{
				new playerveh = GetPlayerVehicleID(playerid);
				SetVehiclePos(playerveh, px, py, pz+2);
				SetVehicleZAngle(playerveh, ang);
				LinkVehicleToInterior(playerveh, Inter);
				PutPlayerInVehicle(playerid, playerveh, 0);
			}
			msgF(id, YELLOW, "**%s Has teleported to you", GetName(playerid));
			msgF(playerid, YELLOW, "**You have teleported to %s", GetName(id));
		}
		return 1;
	}
	CMD:watch(playerid, params[])
	{
		new id;
		if (sscanf(params, "d", id)) msg(playerid, YELLOW, "Usage: /watch [playerid]");
		else if(!IsPlayerConnected(id)) return msg(playerid, RED, "Invalid ID");
		else
		{
			new Float:px, Float:py, Float:pz;
			GetPlayerPos(playerid, px, py, pz);
			WatchPos[0][playerid] = px;
			WatchPos[1][playerid] = py;
			WatchPos[2][playerid] = pz;
			TogglePlayerSpectating(playerid, true);
			if(IsPlayerInAnyVehicle(id)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(id));
			else PlayerSpectatePlayer(playerid, id);
			PlayerSpeccing[playerid] = id;
		}
		return 1;
	}
	CMD:watchoff(playerid, params[])
	{
	#pragma unused params
		if(PlayerSpeccing[playerid] != FreeID)
		{
			TogglePlayerSpectating(playerid, false);
			PlayerSpeccing[playerid] = FreeID;
			SpawnPlayer(playerid);
			SetPlayerPos(playerid, WatchPos[0][playerid], WatchPos[1][playerid], WatchPos[2][playerid]);
		}
		else msg(playerid, RED, "You aren't watching anyone");
		return 1;
	}
	CMD:dmkick(playerid, params[])
	{
		new id, reason[128];
		if(sscanf(params, "ds[128]", id, reason)) return msg(playerid, YELLOW, "Usage: /dmkick [playerid] [reason]");
		else
		{
			ExitDeathmatch(id);
			SpawnPlayer(id);
			msgaF(BLUE, "**%s Has been kicked from the deathmatch, reason: %s", GetName(id), reason);
		}
		return 1;
	}
	CMD:dmban(playerid, params[])
	{
		new id, reason[128];
		if(sscanf(params, "ds[128]", id, reason)) return msg(playerid, YELLOW, "Usage: /dmban [playerid] [reason]");
		else
		{
			ExitDeathmatch(id);
			msgaF(BLUE, "**%s Has been banned from all deathmatches, reason: %s", GetName(id), reason);
			bitTrue(bPlayerGameSettings[playerid], DMbanned);
		}
		return 1;
	}
	CMD:dmunban(playerid, params[])
	{
		new id;
		if(sscanf(params, "d", id)) return msg(playerid, YELLOW, "Usage: /dmunban [playerid]");
		else
		{
			ExitDeathmatch(id);
			msg(id, BLUE, "**You have been un-banned from deathmatches");
			bitFalse(bPlayerGameSettings[playerid], DMbanned);
		}
		return 1;
	}

	//==========================================================================Server Control

	CMD:ann(playerid, params[])
	{
		if(!params[0]) msg(playerid,YELLOW,"Usage: /ann [Message]");
		else
		{
			new s[128+8];
			format(s,sizeof(s),"%s",params);
			GameTextForAll(s, 5000, 5);
		}
		return 1;
	}
	CMD:count(playerid, params[])
	{
		if(ActiveChallenge==0)return 0;
		else
		{
			new tM, tS;
			if(!sscanf(params, "dd", tM, tS))
			{
			    if(tM==0&&tS==0)return StopCountdown();
				if(tM>60||tS>60)return msg(playerid, ORANGE, "Time must be under 60:60");
				StartCountdown(tM, tS);
			}
			else msg(playerid, YELLOW, "Usage: /countdown [minutes] [seconds] If both parameters are 0, timer will be stopped");
		}
		return 1;
	}


	// Countdown Functions (seemed the most appropiate place)

	StartCountdown(m, s)
	{
	    if(s>60)s=60;
		bitTrue(bServerGlobalSettings, CDrunning);
		cdMinute=m;
		cdSecond=s;
	}
	CountDownTimer()
	{
	    new timeStr[8], tmp_sStr[3], tmp_mStr[3];

	    if(cdMinute<10)format(tmp_mStr, 16, "0%d", cdMinute);
	    else format(tmp_mStr, 4, "%d", cdMinute);
	    if(cdSecond<10)format(tmp_sStr, 16, "0%d", cdSecond);
	    else format(tmp_sStr, 4, "%d", cdSecond);

	    format(timeStr, 32, "%s:%s", tmp_mStr, tmp_sStr);
	    TextDrawSetString(CountdownText, timeStr);
	    
		if(cdMinute!=0 && cdSecond==0)cdMinute--, cdSecond=60;
		if(cdMinute==0 && cdSecond==0)StopCountdown();
		cdSecond--;
	}
	StopCountdown()
	{
		if(ActiveChallenge==0)
		{
			GameTextForAll("~r~The marked man escaped!", 3000, 5);
			msgaF(YELLOW, "%s escaped, and won $%d!", GetName(MarkedMan), BankedMoney[MarkedMan]);
			GivePlayerMoney(MarkedMan, BankedMoney[MarkedMan]);
			MarkedMan=FreeID;
			ActiveChallenge=-1;
		}
		else if(ActiveChallenge==1)
		{
			GameTextForAll("~r~The Juggernaut survived!", 3000, 5);
			msgaF(YELLOW, "%s survived, and won $%d!", GetName(Juggernaut), BankedMoney[Juggernaut]);
			GivePlayerMoney(Juggernaut, BankedMoney[Juggernaut]);
			Juggernaut=FreeID;
			ActiveChallenge=-1;
		}
		else GameTextForAll("~r~GO!", 3000, 5);
		bitFalse(bServerGlobalSettings, CDrunning);
		return 1;
	}

#endinput
script_Commands_Admin(playerid, cmd[], params[])
{
	if(pAdmin(playerid) > 0 || IsPlayerAdmin(playerid))
	{
		if(pAdmin(playerid) >= 4 || IsPlayerAdmin(playerid)) // Owner
		{
		    // User
			pCmd(adminlvl, 		8);
		    // Player Control
			pCmd(mclown, 		6);
			pCmd(mpros,			5);
			pCmd(mdance, 		6);
			pCmd(pisser, 		6);
			pCmd(drop,			4);
			pCmd(setname, 		7);
			pCmd(crash,         5);
			pCmd(givegod, 		7);
			pCmd(stopgod, 		7);
			pCmd(view, 			4);
			pCmd(setscore, 		8);
			pCmd(weplock,		7);
			pCmd(godlock,		7);
			// Server Control
			pCmd(motd,          4);
			pCmd(gamename,	  	8);
			pCmd(hostname, 		8);
			pCmd(mapname, 		7);
			pCmd(gmx, 			3);
			pCmd(loadfs, 		6);
			pCmd(reloadfs, 		8);
			pCmd(unloadfs, 		7);
			// Server Players
			pCmd(killall, 		7);
			pCmd(expall, 		6);
			pCmd(kickall, 		7);
			pCmd(suddendeath, 	11);
			pCmd(getall, 		6);
			pCmd(disarmall,		9);
			pCmd(sethealth, 	9);
			pCmd(allhealth, 	9);
			pCmd(msg, 			3);
		}
		if(pAdmin(playerid) >= 3) // Head
		{
		    // User
			pCmd(invis, 		5);
			pCmd(vis, 			3);
		    // Player Control
			pCmd(setadmin,		8);
			pCmd(port, 			4);
			pCmd(fake, 			4);
			pCmd(explode, 		7);
			pCmd(ban, 			3);
			pCmd(unban, 		5);
			pCmd(givewep,	 	7);
			// Server Control
			pCmd(time,			4);
			pCmd(weather,	   	7);
			pCmd(grav,	   		4);
			pCmd(clear,		 	5);
			pCmd(allwep,	 	6);
		}
		if(pAdmin(playerid) >= 2) // Administrator
		{
		    // Player Control
			pCmd(get, 			3);
			pCmd(akill, 		5);
			pCmd(kick, 			4);
			pCmd(freeze, 		6);
			pCmd(unfreeze, 		8);
			pCmd(mute, 			4);
			pCmd(unmute, 		6);
			pCmd(warn,		  	4);
			pCmd(disarm, 		6);
			pCmd(ej, 			2);
		    // Server Control
			pCmd(allheal, 		7);
		}
		if(pAdmin(playerid) >= 1) // Moderator
		{
		    // User Commands
			pCmd(god,			3);
			pCmd(health, 		6);
			// Player Control
			pCmd(givecar, 		7);
			pCmd(heal, 			4);
			pCmd(goto, 			4);
			pCmd(watch,			5);
			pCmd(watchoff,		8);
			pCmd(dmkick,		6);
			pCmd(dmban,			5);
			pCmd(dmunban,		7);
			// Server Control
			pCmd(ann, 			3);
			pCmd(count, 		5);
		}
	}
	return 0;
}

